﻿using FluentNHibernate.Mapping;
using EntitiesAndMappings.Entities;

namespace EntitiesAndMappings.Mappings
{
    public class SalidaMap : ClassMap<Salida>
    {
        public SalidaMap()
        {

            Id(x => x.Id).GeneratedBy.Native();
            References(x => x.TipoMovimiento).LazyLoad(Laziness.False).Not.Nullable();
            Map(x => x.Fecha).Not.Nullable();
            References(x => x.Proveedor).LazyLoad(Laziness.False).Not.Nullable();
            Map(x => x.NumeroGuia).Length(50).Not.Nullable();
            Map(x => x.OrdenServicio).Length(50).Not.Nullable();
            References(x => x.Almacen).LazyLoad(Laziness.False).Nullable();
            References(x => x.Proyecto).LazyLoad(Laziness.False).Nullable();
            References(x => x.Lote).LazyLoad(Laziness.False).Nullable();
            References(x => x.Lugar).LazyLoad(Laziness.False).Nullable();           
            Map(x => x.Ubicacion).Nullable();
            HasMany(x => x.Items).Inverse().AsBag().Cascade.AllDeleteOrphan(); 
        }
    }
}
